All Questions
6 questions
3votes
2answers
1kviews
Counting the number of ways to decode a string
I am working on problem where I need to decode a string: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... '...
3votes
3answers
2kviews
Tower Hopper problem recursive approach
The Tower Hopper problem gives us an array of values representing heights that express how far we can jump from a certain tower, and asks whether there's a way to get from ...
3votes
1answer
442views
Find the maximum possible summation of differences of consecutive elements
Array A contains the elements, \$A_1,A_2, \ldots, A_N\$. And array B contains the elements, \$B_1,B_2, \ldots, B_N\$. There is a relationship between \$A_i\$ and \$B_i\$: any element \$A_i\$ ...
2votes
1answer
103views
dynamic programming solution for a string ending with 0, 1 or 2
A string that contains only 0s, 1s, and 2s is called a ternary string. Find a total ternary ...
1vote
1answer
843views
Compute the number of ways a given amount (cents) can be changed
Given an infinite number of different coin types (such as pennies, nickels, dimes, quarters) find out how many ways n cents can be represented. My code appears to work (although I am curious to ...
6votes
1answer
3kviews
Longest common subsequence length and backtracking the string
Problem: Given two sequences, print the longest subsequence present in both of them. A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. For example, “...